<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="style/js/jquery-1.11.0.min.js"></script>
		<script type="text/javascript" src="style/js/echarts.js" ></script>
		<style>
			#main{
	width: 100%;
	height: 400px;
	line-height: 400px;
	margin: 0 auto;
	align-content: center;
	margin-top: 30px;
}
		</style>
		<script>
			$(function(){
				
			var $_GET = (function(){
		    var url = window.document.location.href.toString();
		    var u = url.split("?");
		    if(typeof(u[1]) == "string"){
		        u = u[1].split("&");
		        var get = {};
		        for(var i in u){
		            var j = u[i].split("=");
		            get[j[0]] = j[1];
		        }
		        return get;
		    } else {
		        return {};
		    }
		});
				console.log($_GET().aa);
				
				//var url="http://192.168.11.130:10001/V1/app/getPageLoadeTime?currentPage="+$_GET().pageName+"&timeLines=0&timeLines=10&timeLines=20&timeLines=50&timeLines=100";
				var url="http://112.74.51.64:20002/api/V1/app/getPageLoadeTime?currentPage="+$_GET().pageName+"&timeLines=0&timeLines=10&timeLines=20&timeLines=50&timeLines=100";
				console.log(url);
				$.ajax({
					type:"get",
					url:url,
					dataType:'jsonp',
					processData:false,
					success:function(data){
						var time=[];
					//	var dataNum=[];
			var list=data.data.loadTime;
			var str=list.split(",");
			for(var i=0;i<str.length;i++){
				time.push(str[i]);
			}
			var myChart = echarts.init(document.getElementById('main'));
		var	xMessage = ["0-10毫秒", "10-20毫秒", "20-50毫秒","50-100毫秒","100毫秒以上"];
				var option={
					title: {
					show: true,
					text: '页面加载时长',
					subtext: '单位(次)',
				},
				toolbox: {
					show: true,
					orient: 'horizontal',
					showTitle: true,
					right: 50,
					feature: {
						dataView: {
							show: true,
						},
						saveAsImage: {
							show: true,
						},
						magicType: {
							type: ['line', 'bar', 'stack', 'tiled']
						},
						restore :{
							show: true
						}
					}

				},
				tooltip: {

				},
				legend: {
					data: '页面加载时长'
					//datat:['停留时长','访问时长'];
				},
				xAxis: {
					data: xMessage
				},
				yAxis: {
					axisLabel: {
						min: 0,
						max: 80,
						interval: 10,
						formatter: '{value} 次'
					}
				},
						series: [{
						name: '页面加载时长',
						type: 'bar',
						barWidth: 50,
						data: time,
						itemStyle: {
							normal: {
								color: '#B5C334'
							}
						},
					},
					{
						name: '页面加载时长',
						type: 'line',
						barWidth: 50,
						data: time,
					}
				]
					};
					myChart.setOption(option);
					}
				});
				
				
				$("#confirm").click(function(){
				var platform=$("#platform option:selected").val();
				console.log(platform);
				startTime=$("#startTime").val();
				startTime=startTime.replace(new RegExp("-","gm"),"/").replace(new RegExp("T","gm")," ");
				var startTime1= (new Date(startTime)).getTime()/1000;
				console.log(startTime1);
				 endTime=$("#endTime").val();
				 endTime= endTime.replace(new RegExp("-","gm"),"/").replace(new RegExp("T","gm")," ");
				var endTime1= (new Date(endTime)).getTime()/1000;
				console.log(endTime1);
				
				var project=$("#project option:selected").val();
				console.log(project);
				if(isNaN(startTime1)){
					startTime1="";
				}
				if(isNaN(endTime1)){
					endTime1="";
				}
				var url;
				if(project==1){
					//url="http://192.168.11.130:10001/V1/app/getPageLoadeTime?currentPage="+$_GET().pageName+"&startData="+startTime1+"&endData="+endTime1+"&timeLines=5&timeLines=10&timeLines=20&timeLines=50&timeLines=100"
					url="http://112.74.51.64:20002/api/V1/app/getPageLoadeTime?currentPage="+$_GET().pageName+"&startData="+startTime1+"&endData="+endTime1+"&timeLines=5&timeLines=10&timeLines=20&timeLines=50&timeLines=100"
				}else if(project==2){
					//url="http://192.168.11.130:10001/V1/app/getPageLoadeTime?currentPage="+$_GET().pageName+"&startData="+startTime1+"&endData="+endTime1+"&stayTimes=5&stayTimes=15&stayTimes=30&stayTimes=60&stayTimes=180"
					url="http://112.74.51.64:20002/api/V1/app/getPageLoadeTime?currentPage="+$_GET().pageName+"&startData="+startTime1+"&endData="+endTime1+"&stayTimes=5&stayTimes=15&stayTimes=30&stayTimes=60&stayTimes=180"
				}else if(project==0){
					alert("请选择项目");
					return false;
				}
				console.log(url);
				$.ajax({
					type:"get",
					url:url,
					dataType:'jsonp',      
					processData:false,
					success:function(data){
						var loadDatat=[];
						var xMessage =null;
						var title=null;
						if(project==1){
						var str =data.data.loadTime;
						console.log(str);
						var str=str.split(",");
						for(var i=0;i<str.length;i++){		
							loadDatat.push(str[i]);
							}
						title="页面加载时间";
						xMessage=["0-5毫秒", "5-10毫秒", "10-20毫秒","20-50毫秒","50-100毫秒","100毫秒以上"];
						}else if(project==2){
							var str =data.data.stayTime;
								console.log(str);
						var str=str.split(",");
						for(var i=0;i<str.length;i++){		
							loadDatat.push(str[i]);
							}
						title="页面停留时间";
						xMessage=["0-5秒", "5-15毫秒", "15-30毫秒","30-60毫秒","1-3分钟","3分钟以上"];
						}
						
				var myChart1 = echarts.init(document.getElementById('main'));
				var option={
					title: {
					show: true,
					text: title,
					subtext: '单位(次)',
				},
				toolbox: {
					show: true,
					orient: 'horizontal',
					showTitle: true,
					right: 50,
					feature: {
						dataView: {
							show: true,
						},
						saveAsImage: {
							show: true,
						},
						magicType: {
							type: ['line', 'bar', 'stack', 'tiled']
						},
						restore :{
							show: true
						}
					}

				},
				tooltip: {

				},
				legend: {
					data: title
					//datat:['停留时长','访问时长'];
				},
				xAxis: {
					data: xMessage
				},
				yAxis: {
					axisLabel: {
						min: 0,
						max: 80,
						interval: 10,
						formatter: '{value} 次'
					}
				},
						series: [{
						name: title,
						type: 'bar',
						barWidth: 50,
						data: loadDatat,
						itemStyle: {
							normal: {
								color: '#B5C334'
							}
						},
					},
					{
						name: title,
						type: 'line',
						barWidth: 50,
						data: loadDatat,
					}
				]
				};
				myChart1.setOption(option);
						
					}
				});
				
				});
				
			});
		</script>
	</head>
	<body>
		<div align="center">
			<select id="platform">
			<option value="0">请选择平台</option>
			<option value="1">android</option>
			<option value="2">ios</option>
		</select>
		
			<select id="project">
			<option value="0">请选择项目</option>
			<option value="1">页面加载</option>
			<option value="2">页面停留</option>
		</select>
		<span >日期选择:</span>
		<input type="datetime-local"  id="startTime" style="margin-top: 30px;"/>
		<input type="datetime-local" id="endTime" />
		
		<input type="button" value="确定" id="confirm"/>
		</div>
		<div id="main">
			
		</div>
		
	</body>
</html>
